
void cmd_loop(istringstream& ss) {
  if(looplevel==0) {
    if(!(ss>>nloop)) throw "invalid loop command";
    looplevel=1;
    loopbreak=false;
  } else {
    string lcmd=getall(ss);
    if(remove_char(lcmd," ;")=="end") { // execute loop command set
      looplevel--;
      for(loopcounter=0;loopcounter<nloop;loopcounter++) {
        parse(loopcmd);
        if(loopbreak) {
          std::cerr<<getpid()<<":"<<me<<" is broken (press crtl-C)\n";
          break;
        }
      }
      loopcmd.clear();
      if(looplevel<0) throw "invalid loop";
    } else {
      if(lcmd.substr(0,4)=="loop") throw "invalid loop command";
      loopcmd.append(lcmd+";");
    }
  }
}
